#pragma once
#include <src/algorithm/1DSolver/Newton_Raphson.h>
#include <src/data/ParticleSet.h>
#include <src/data/Operators.h>
#include <src/data/Polynomials.h>

template <class I> 
struct newton_raphson_example {
	struct f : public derivable< I >
	{
		typedef typename derivable< I >::Base Base;
		struct f_diff : public Base 
		{
			result_type operator()(argument_type x) const
			{ 
				return (((5. * x - 40.) * x + 105.) * x - 100.) * x + 24.;
			};
		};
		result_type operator()(argument_type x) const
		{ 
			return x * (x - 1.) * (x - 2.) * (x - 3.) * (x - 4.); 
		};
		virtual smart_ptr_function get_derivative() const {
			return smart_ptr_function( new f_diff);
		};

	};
	struct test_polynomial_algebra : public polynomial<I,particle<OS_double>>
	{
		typedef typename polynomial<I,particle<OS_double>> polynomial_type;
		test_polynomial_algebra(const polynomial_type &from) : polynomial_type(from) {};
		test_polynomial_algebra(){
			polynomial_type x = polynomial_canonical_base<polynomial_type>()[1];
			(*this) = x * (x - 1.) * (x - 2.) * (x - 3.) * (x - 4.);
		};

		virtual I operator()(const I & x) const
		{
		  I breakpoint = polynomial_type::operator ()(x);
		   return breakpoint;
		};
	};

};


void newton_raphson_test();
